/* ************************************************************************** */
/* Example of a syndication feed reader using the Project Rome API with       */
/* BSF4ooRexx                                                                 */
/* current version of Rome: rome1.0.jar            https://rome.dev.java.net/ */
/* You need to implement this API plus the JDOM API                           */
/* jdom.jar  ,   you can find this at               https://jdom.org/        ; */
/*                                                                            */
/* This is a simple example of how to create a WireFeed feed with ooRexx      */                
/* created by Martin Stoppacher     date:   26.12.2009    (c) 2009            */
/* license:ÊÊÊÊLGPL 3.0ÊÊÊÊÊÊÊused versions: Java 1.6, ooRexx 4.0, Bsf4ooRexx */
/*             (Lesser Gnu Public License version 3.0),                       */
/*             cf. <http://www.gnu.org/licenses/lgpl.html>                    */
/* ************************************************************************** */

say "hello this creates a syndfeeds"

--pull typet  /* optional type input */
typet = "atom_0.3"
--typet = "rss_1.0"
fileName = "test6_new_feed" typet

DATE_PARSER = .bsf~new("java.text.SimpleDateFormat", "yyyy-MM-dd")

say 'Your crated feed starts hear :'

feed=.bsf~new("com.sun.syndication.feed.atom.Feed",typet)

/*      using syndfeedImpl to creat a feed using the independent object model */
--feed~setFeedType(typet)

/*                                                 sets the type of this feed */

feed~setTitle("This is a simple Sample")
feed~setRights("using WireFeed")
feed~setUpdated(DATE_PARSER~parse("2010-01-01"))

/*                                                                writer part */
--writer=.bsf~new("java.io.FileWriter",fileName)
output=.bsf~new("com.sun.syndication.io.WireFeedOutput")
--output~output(feed,writer)
--writer~close()

say output~outputString(feed,1) -- usage of pretty print(0 yes or 1 no)

PP : RETURN "[" || ARG(1)|| "]"

::requires BSF.cls